package com.toraeve.asktora.domain.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;

/**
 * User. Notice that, the default value is a valid user. that is, fields:
 * <code>expired, locked, credentialsExpired</code> are set to
 * <code><i>false</i></code>, field:<code>enabled</code> is set to
 * <code><i>true</i></code>
 * 
 * @author larry.li
 * 
 */
public class ToraUser implements Serializable {

	private static final long serialVersionUID = 1L;

	private String email;
	private String username;
	private String password;
	private boolean male = true;
	private boolean expired = false;
	private boolean locked = false;
	private boolean credentialsExpired = false;
	private boolean enabled = true;

	private Collection<String> role = new HashSet<String>();

	public ToraUser(String email) {
		this.email = email;
	}

	public void addRole(String roleName) {
		this.role.add(roleName);
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public Collection<String> getRole() {
		return role;
	}

	public void setRole(Collection<String> role) {
		this.role = role;
	}

	public String getEmail() {
		return email;
	}

	public boolean isMale() {
		return male;
	}

	public void setMale(boolean male) {
		this.male = male;
	}

	public boolean isExpired() {
		return expired;
	}

	public void setExpired(boolean expired) {
		this.expired = expired;
	}

	public boolean isLocked() {
		return locked;
	}

	public void setLocked(boolean locked) {
		this.locked = locked;
	}

	public boolean isCredentialsExpired() {
		return credentialsExpired;
	}

	public void setCredentialsExpired(boolean credentialsExpired) {
		this.credentialsExpired = credentialsExpired;
	}

	@Override
	public String toString() {
		return "ToraUser [email=" + email + ", username=" + username
				+ ", password=" + password + ", male=" + male + ", expired="
				+ expired + ", locked=" + locked + ", credentialsExpired="
				+ credentialsExpired + ", enabled=" + enabled + ", role="
				+ role + "]";
	}

}
